package com.hongyuan.sellfitness.ui.person.view_mode;

import android.app.Application;
import androidx.annotation.NonNull;
import com.hongyuan.mvvmhabitx.bus.event.SingleLiveEvent;
import com.hongyuan.sellfitness.base.Constants;
import com.hongyuan.sellfitness.base.CustomViewModel;
import com.hongyuan.sellfitness.data.MyRepository;
import com.hongyuan.sellfitness.ui.person.beans.CouponHubTop;

import java.util.List;

public class CouponHubModel extends CustomViewModel<MyRepository> {

    public CouponHubModel(@NonNull Application application, MyRepository model) {
        super(application, model);
    }

    //封装一个界面发生改变的观察者
    public UIChangeObservable uc = new UIChangeObservable();
    public class UIChangeObservable {
        //设置头部数据
        public SingleLiveEvent<List<CouponHubTop>> setHead = new SingleLiveEvent<>();

    }

    @Override
    protected void returnData(int code, Object dataBean) {
        super.returnData(code, dataBean);

        if(code == Constants.COUPON_FOR_LIST){
            List<CouponHubTop> mList = (List<CouponHubTop>) dataBean;

            uc.setHead.setValue(mList);

        }
    }

}
